﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Data.SqlClient;
using System.Data;
using MySql.Data.MySqlClient;
using System.Text;

namespace DA
{
    public class Access_Level : GO.BaseClass
    {
        public VO.Access_Level objVO;

        public Access_Level()
        {
            objVO = new VO.Access_Level();
            sbSQL = new StringBuilder();
        }

        public void Salvar()
        {
            // MONTA A INSTRUÇÃO SQL
            sbSQL.Append(" INSERT INTO `Access_Level` (Nivel) ");
            sbSQL.Append(" VALUES('p_Nivel'); ");

            // SUBSTITUI OS PARÂMETROS
            sbSQL.Replace("p_Nivel", objVO.Nivel);

            // EXECUTA INSTRUÇÃO
            GO.MySQLHelper.ExecuteNonQuery(getConn(), sbSQL.ToString(), CommandType.Text);

            // LIMPA VARIÁVEL
            sbSQL.Remove(0, sbSQL.Length);
        }

        public void Atualizar()
        {
            // MONTA A INSTRUÇÃO SQL
            sbSQL.Append(" UPDATE `Access_Level` SET");
            sbSQL.Append("     Nivel  = 'p_Nivel ',");
            sbSQL.Append(" WHERE ");
            sbSQL.Append(" 	   idLevel   = p_idLevel  ;        ");

            // SUBSTITUI OS PARÂMETROS
            sbSQL.Replace("p_idLevel", objVO.IdLevel.ToString());
            sbSQL.Replace("p_Nivel", objVO.Nivel);

            GO.MySQLHelper.ExecuteNonQuery(getConn(), sbSQL.ToString(), CommandType.Text);

            sbSQL.Remove(0, sbSQL.Length);
        }

        public void Excluir()
        {
            sbSQL.Append(" DELETE FROM `Access_Level` ");
            sbSQL.Append(" WHERE idLevel   = p_idLevel  ; ");

            // SUBSTITUI OS PARÂMETROS
            sbSQL.Replace("p_idLevel", objVO.IdLevel.ToString());

            GO.MySQLHelper.ExecuteNonQuery(getConn(), sbSQL.ToString(), CommandType.Text);
        }

        //public DataSet getTodosRegistros()
        //{

        //    //sbSQL.Append(" SELECT * FROM `Eventos`; ");

        //    //return GO.MySQLHelper.ExecuteDataset(getConn(), sbSQL.ToString(), CommandType.Text);
        //}

        //public DataSet getRegistroById()
        //{
        //    //sbSQL.Append(" SELECT * FROM `Eventos` ");
        //    //sbSQL.Append(" WHERE idEvento = p_idEvento; ");
        //    //sbSQL.Replace("p_idEvento", objVO.IdEvento.ToString());

        //    //return GO.MySQLHelper.ExecuteDataset(getConn(), sbSQL.ToString(), CommandType.Text);
        //}
    }
}
